package com.qidianit.mes.production.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qidianit.mes.common.pojo.MesResult;
import com.qidianit.mes.production.service.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.qidianit.mes.pojo.Process;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 * @date 2025/8/4 9:54
 * @description
 */
@RestController
@RequestMapping("/process")
public class ProcessController {
    @Autowired
    private ProcessService processService;
    @DeleteMapping("/deletes")
    public MesResult<Integer> deleteBatch( String[] processCode) {
        return processService.deleteBatch(processCode);
    }
    @DeleteMapping("/{processCode}")
    public MesResult<Integer> removeProcess(@PathVariable String processCode) {
        return processService.removeProcess(processCode);
    }
    @PutMapping
    public MesResult<Integer> updateProcess(@RequestBody Process process) {
        return processService.updateProcess(process);
    }
    @GetMapping("/{processCode}")
    public MesResult<Process> getProcessByCode(@PathVariable String processCode) {
        return processService.getProcessById(processCode);
    }
    @PostMapping
    public MesResult<Integer> createProcess(@RequestBody Process process) {
        return processService.saveProcess( process);
    }

    @GetMapping("/codeGen")
    public MesResult<String> getProcessCode() {
        return processService.getProcessCode();
    }

    @GetMapping("/list")
    public MesResult<Page<Process>> list(Process process, @RequestParam(defaultValue = "1")int pageNum, @RequestParam(defaultValue = "10") int pageSize){
        // 在这里组件wrapper controller只是接收请求，绑定参数，响应客户端，不做业务或者查询条件封装。。。。
        return processService.listProcess(process, pageNum, pageSize);
    }
}
